<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE DeriveDataTypeable #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE ExistentialQuantification #-}</span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# LANGUAGE FlexibleContexts #-}</span><span>
</span><span id="line-5"></span><span class="hs-pragma">{-# LANGUAGE StandaloneDeriving #-}</span><span>
</span><span id="line-6"></span><span class="hs-pragma">{-# LANGUAGE Safe #-}</span><span>
</span><span id="line-7"></span><span>
</span><span id="line-8"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Module      :  Text.Parsec.Perm</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Copyright   :  (c) Daan Leijen 1999-2001, (c) Paolo Martini 2007</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- License     :  BSD-style (see the file libraries/parsec/LICENSE)</span><span>
</span><span id="line-13"></span><span class="hs-comment">--</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Maintainer  :  derek.a.elkins@gmail.com</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Stability   :  provisional</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- Portability :  non-portable (uses existentially quantified data constructors)</span><span>
</span><span id="line-17"></span><span class="hs-comment">--</span><span>
</span><span id="line-18"></span><span class="hs-comment">-- This module implements permutation parsers. The algorithm used</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- is fairly complex since we push the type system to its limits :-)</span><span>
</span><span id="line-20"></span><span class="hs-comment">-- The algorithm is described in:</span><span>
</span><span id="line-21"></span><span class="hs-comment">--</span><span>
</span><span id="line-22"></span><span class="hs-comment">-- /Parsing Permutation Phrases,/</span><span>
</span><span id="line-23"></span><span class="hs-comment">-- by Arthur Baars, Andres Loh and Doaitse Swierstra.</span><span>
</span><span id="line-24"></span><span class="hs-comment">-- Published as a functional pearl at the Haskell Workshop 2001.</span><span>
</span><span id="line-25"></span><span class="hs-comment">--</span><span>
</span><span id="line-26"></span><span class="hs-comment">-- From the abstract: </span><span>
</span><span id="line-27"></span><span class="hs-comment">--</span><span>
</span><span id="line-28"></span><span class="hs-comment">-- A permutation phrase is a sequence of elements (possibly of different types) </span><span>
</span><span id="line-29"></span><span class="hs-comment">-- in which each element occurs exactly once and the order is irrelevant. </span><span>
</span><span id="line-30"></span><span class="hs-comment">-- Some of the permutable elements may be optional.</span><span>
</span><span id="line-31"></span><span class="hs-comment">--</span><span>
</span><span id="line-32"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-33"></span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Text.Parsec.Perm</span><span>
</span><span id="line-36"></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#PermParser"><span class="hs-identifier">PermParser</span></a></span><span>
</span><span id="line-37"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#StreamPermParser"><span class="hs-identifier">StreamPermParser</span></a></span><span> </span><span class="hs-comment">-- abstract</span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#permute"><span class="hs-identifier">permute</span></a></span><span>
</span><span id="line-40"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#%3C%7C%7C%3E"><span class="hs-operator">(&lt;||&gt;)</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#%3C%24%24%3E"><span class="hs-operator">(&lt;$$&gt;)</span></a></span><span>
</span><span id="line-41"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#%3C%7C%3F%3E"><span class="hs-operator">(&lt;|?&gt;)</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#%3C%24%3F%3E"><span class="hs-operator">(&lt;$?&gt;)</span></a></span><span>
</span><span id="line-42"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-43"></span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Text.Parsec.html"><span class="hs-identifier">Text.Parsec</span></a></span><span>
</span><span id="line-45"></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../mtl/src/Control.Monad.Identity.html#"><span class="hs-identifier">Control.Monad.Identity</span></a></span><span class="hs-cpp">
#if MIN_VERSION_base(4,7,0)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Typeable.html#"><span class="hs-identifier">Data.Typeable</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.Typeable.Internal.html#Typeable"><span class="hs-identifier">Typeable</span></a></span><span> </span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span class="hs-comment">-- For GHC 7.6</span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Data.Typeable</span><span> </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">Typeable3</span><span> </span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-54"></span><span class="hs-keyword">infixl</span><span> </span><span class="hs-number">1</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#%3C%7C%7C%3E"><span class="hs-operator hs-type">&lt;||&gt;</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#%3C%7C%3F%3E"><span class="hs-operator hs-type">&lt;|?&gt;</span></a></span><span>
</span><span id="line-55"></span><span class="hs-keyword">infixl</span><span> </span><span class="hs-number">2</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#%3C%24%24%3E"><span class="hs-operator hs-type">&lt;$$&gt;</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#%3C%24%3F%3E"><span class="hs-operator hs-type">&lt;$?&gt;</span></a></span><span>
</span><span id="line-56"></span><span>
</span><span id="line-57"></span><span>
</span><span id="line-58"></span><span class="hs-comment">{---------------------------------------------------------------
  test -- parse a permutation of
  * an optional string of 'a's
  * a required 'b'
  * an optional 'c'
---------------------------------------------------------------}</span><span>
</span><span id="line-64"></span><span class="hs-comment">{-
test input
  = parse (do{ x &lt;- ptest; eof; return x }) &quot;&quot; input

ptest :: Parser (String,Char,Char)
ptest
  = permute $
    (,,) &lt;$?&gt; (&quot;&quot;,many1 (char 'a'))
         &lt;||&gt; char 'b'
         &lt;|?&gt; ('_',char 'c')
-}</span><span>
</span><span id="line-75"></span><span>
</span><span id="line-76"></span><span class="hs-comment">{---------------------------------------------------------------
  Building a permutation parser
---------------------------------------------------------------}</span><span>
</span><span id="line-79"></span><span>
</span><span id="line-80"></span><span class="hs-comment">-- | The expression @perm \&lt;||&gt; p@ adds parser @p@ to the permutation</span><span>
</span><span id="line-81"></span><span class="hs-comment">-- parser @perm@. The parser @p@ is not allowed to accept empty input -</span><span>
</span><span id="line-82"></span><span class="hs-comment">-- use the optional combinator ('&lt;|?&gt;') instead. Returns a</span><span>
</span><span id="line-83"></span><span class="hs-comment">-- new permutation parser that includes @p@.</span><span>
</span><span id="line-84"></span><span>
</span><span id="line-85"></span><span id="local-6989586621679061263"><span id="local-6989586621679061264"><span id="local-6989586621679061265"><span id="local-6989586621679061267"><span id="local-6989586621679061269"><span class="annot"><a href="Text.Parsec.Perm.html#%3C%7C%7C%3E"><span class="hs-operator hs-type">(&lt;||&gt;)</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Prim.html#Stream"><span class="hs-identifier hs-type">Stream</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061269"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="../../base/src/Data.Functor.Identity.html#Identity"><span class="hs-identifier hs-type">Identity</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061267"><span class="hs-identifier hs-type">tok</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#StreamPermParser"><span class="hs-identifier hs-type">StreamPermParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061269"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061265"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679061264"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679061263"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Prim.html#Parsec"><span class="hs-identifier hs-type">Parsec</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061269"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061265"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061264"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#StreamPermParser"><span class="hs-identifier hs-type">StreamPermParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061269"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061265"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061263"><span class="hs-identifier hs-type">b</span></a></span></span></span></span></span></span><span>
</span><span id="line-86"></span><span id="%3C%7C%7C%3E"><span class="annot"><span class="annottext">&lt;||&gt; :: forall s tok st a b.
Stream s Identity tok =&gt;
StreamPermParser s st (a -&gt; b)
-&gt; Parsec s st a -&gt; StreamPermParser s st b
</span><a href="Text.Parsec.Perm.html#%3C%7C%7C%3E"><span class="hs-operator hs-var hs-var">(&lt;||&gt;)</span></a></span></span><span> </span><span id="local-6989586621679061124"><span class="annot"><span class="annottext">StreamPermParser s st (a -&gt; b)
</span><a href="#local-6989586621679061124"><span class="hs-identifier hs-var">perm</span></a></span></span><span> </span><span id="local-6989586621679061123"><span class="annot"><span class="annottext">Parsec s st a
</span><a href="#local-6989586621679061123"><span class="hs-identifier hs-var">p</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StreamPermParser s st (a -&gt; b)
-&gt; Parsec s st a -&gt; StreamPermParser s st b
forall s tok st a b.
Stream s Identity tok =&gt;
StreamPermParser s st (a -&gt; b)
-&gt; Parsec s st a -&gt; StreamPermParser s st b
</span><a href="Text.Parsec.Perm.html#add"><span class="hs-identifier hs-var">add</span></a></span><span> </span><span class="annot"><span class="annottext">StreamPermParser s st (a -&gt; b)
</span><a href="#local-6989586621679061124"><span class="hs-identifier hs-var">perm</span></a></span><span> </span><span class="annot"><span class="annottext">Parsec s st a
</span><a href="#local-6989586621679061123"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-87"></span><span>
</span><span id="line-88"></span><span class="hs-comment">-- | The expression @f \&lt;$$&gt; p@ creates a fresh permutation parser</span><span>
</span><span id="line-89"></span><span class="hs-comment">-- consisting of parser @p@. The the final result of the permutation</span><span>
</span><span id="line-90"></span><span class="hs-comment">-- parser is the function @f@ applied to the return value of @p@. The</span><span>
</span><span id="line-91"></span><span class="hs-comment">-- parser @p@ is not allowed to accept empty input - use the optional</span><span>
</span><span id="line-92"></span><span class="hs-comment">-- combinator ('&lt;$?&gt;') instead.</span><span>
</span><span id="line-93"></span><span class="hs-comment">--</span><span>
</span><span id="line-94"></span><span class="hs-comment">-- If the function @f@ takes more than one parameter, the type variable</span><span>
</span><span id="line-95"></span><span class="hs-comment">-- @b@ is instantiated to a functional type which combines nicely with</span><span>
</span><span id="line-96"></span><span class="hs-comment">-- the adds parser @p@ to the ('&lt;||&gt;') combinator. This</span><span>
</span><span id="line-97"></span><span class="hs-comment">-- results in stylized code where a permutation parser starts with a</span><span>
</span><span id="line-98"></span><span class="hs-comment">-- combining function @f@ followed by the parsers. The function @f@</span><span>
</span><span id="line-99"></span><span class="hs-comment">-- gets its parameters in the order in which the parsers are specified,</span><span>
</span><span id="line-100"></span><span class="hs-comment">-- but actual input can be in any order.</span><span>
</span><span id="line-101"></span><span>
</span><span id="line-102"></span><span id="local-6989586621679061251"><span id="local-6989586621679061252"><span id="local-6989586621679061253"><span id="local-6989586621679061254"><span id="local-6989586621679061255"><span class="annot"><a href="Text.Parsec.Perm.html#%3C%24%24%3E"><span class="hs-operator hs-type">(&lt;$$&gt;)</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Prim.html#Stream"><span class="hs-identifier hs-type">Stream</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061255"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="../../base/src/Data.Functor.Identity.html#Identity"><span class="hs-identifier hs-type">Identity</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061254"><span class="hs-identifier hs-type">tok</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679061253"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679061252"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Prim.html#Parsec"><span class="hs-identifier hs-type">Parsec</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061255"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061251"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061253"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#StreamPermParser"><span class="hs-identifier hs-type">StreamPermParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061255"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061251"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061252"><span class="hs-identifier hs-type">b</span></a></span></span></span></span></span></span><span>
</span><span id="line-103"></span><span id="%3C%24%24%3E"><span class="annot"><span class="annottext">&lt;$$&gt; :: forall s tok a b st.
Stream s Identity tok =&gt;
(a -&gt; b) -&gt; Parsec s st a -&gt; StreamPermParser s st b
</span><a href="Text.Parsec.Perm.html#%3C%24%24%3E"><span class="hs-operator hs-var hs-var">(&lt;$$&gt;)</span></a></span></span><span> </span><span id="local-6989586621679061118"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679061118"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679061117"><span class="annot"><span class="annottext">Parsec s st a
</span><a href="#local-6989586621679061117"><span class="hs-identifier hs-var">p</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a -&gt; b) -&gt; StreamPermParser s st (a -&gt; b)
forall s tok a b st.
Stream s Identity tok =&gt;
(a -&gt; b) -&gt; StreamPermParser s st (a -&gt; b)
</span><a href="Text.Parsec.Perm.html#newperm"><span class="hs-identifier hs-var">newperm</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679061118"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">StreamPermParser s st (a -&gt; b)
-&gt; Parsec s st a -&gt; StreamPermParser s st b
forall s tok st a b.
Stream s Identity tok =&gt;
StreamPermParser s st (a -&gt; b)
-&gt; Parsec s st a -&gt; StreamPermParser s st b
</span><a href="Text.Parsec.Perm.html#%3C%7C%7C%3E"><span class="hs-operator hs-var">&lt;||&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Parsec s st a
</span><a href="#local-6989586621679061117"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-104"></span><span>
</span><span id="line-105"></span><span class="hs-comment">-- | The expression @perm \&lt;||&gt; (x,p)@ adds parser @p@ to the</span><span>
</span><span id="line-106"></span><span class="hs-comment">-- permutation parser @perm@. The parser @p@ is optional - if it can</span><span>
</span><span id="line-107"></span><span class="hs-comment">-- not be applied, the default value @x@ will be used instead. Returns</span><span>
</span><span id="line-108"></span><span class="hs-comment">-- a new permutation parser that includes the optional parser @p@.</span><span>
</span><span id="line-109"></span><span>
</span><span id="line-110"></span><span id="local-6989586621679061236"><span id="local-6989586621679061237"><span id="local-6989586621679061238"><span id="local-6989586621679061239"><span id="local-6989586621679061240"><span class="annot"><a href="Text.Parsec.Perm.html#%3C%7C%3F%3E"><span class="hs-operator hs-type">(&lt;|?&gt;)</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Prim.html#Stream"><span class="hs-identifier hs-type">Stream</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061240"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="../../base/src/Data.Functor.Identity.html#Identity"><span class="hs-identifier hs-type">Identity</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061239"><span class="hs-identifier hs-type">tok</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#StreamPermParser"><span class="hs-identifier hs-type">StreamPermParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061240"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061238"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679061237"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679061236"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679061237"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Text.Parsec.Prim.html#Parsec"><span class="hs-identifier hs-type">Parsec</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061240"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061238"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061237"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#StreamPermParser"><span class="hs-identifier hs-type">StreamPermParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061240"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061238"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061236"><span class="hs-identifier hs-type">b</span></a></span></span></span></span></span></span><span>
</span><span id="line-111"></span><span id="%3C%7C%3F%3E"><span class="annot"><span class="annottext">&lt;|?&gt; :: forall s tok st a b.
Stream s Identity tok =&gt;
StreamPermParser s st (a -&gt; b)
-&gt; (a, Parsec s st a) -&gt; StreamPermParser s st b
</span><a href="Text.Parsec.Perm.html#%3C%7C%3F%3E"><span class="hs-operator hs-var hs-var">(&lt;|?&gt;)</span></a></span></span><span> </span><span id="local-6989586621679061113"><span class="annot"><span class="annottext">StreamPermParser s st (a -&gt; b)
</span><a href="#local-6989586621679061113"><span class="hs-identifier hs-var">perm</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679061112"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679061112"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679061111"><span class="annot"><span class="annottext">Parsec s st a
</span><a href="#local-6989586621679061111"><span class="hs-identifier hs-var">p</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StreamPermParser s st (a -&gt; b)
-&gt; a -&gt; Parsec s st a -&gt; StreamPermParser s st b
forall s tok st a b.
Stream s Identity tok =&gt;
StreamPermParser s st (a -&gt; b)
-&gt; a -&gt; Parsec s st a -&gt; StreamPermParser s st b
</span><a href="Text.Parsec.Perm.html#addopt"><span class="hs-identifier hs-var">addopt</span></a></span><span> </span><span class="annot"><span class="annottext">StreamPermParser s st (a -&gt; b)
</span><a href="#local-6989586621679061113"><span class="hs-identifier hs-var">perm</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679061112"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Parsec s st a
</span><a href="#local-6989586621679061111"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-112"></span><span>
</span><span id="line-113"></span><span class="hs-comment">-- | The expression @f \&lt;$?&gt; (x,p)@ creates a fresh permutation parser</span><span>
</span><span id="line-114"></span><span class="hs-comment">-- consisting of parser @p@. The the final result of the permutation</span><span>
</span><span id="line-115"></span><span class="hs-comment">-- parser is the function @f@ applied to the return value of @p@. The</span><span>
</span><span id="line-116"></span><span class="hs-comment">-- parser @p@ is optional - if it can not be applied, the default value</span><span>
</span><span id="line-117"></span><span class="hs-comment">-- @x@ will be used instead.</span><span>
</span><span id="line-118"></span><span>
</span><span id="line-119"></span><span id="local-6989586621679061221"><span id="local-6989586621679061222"><span id="local-6989586621679061223"><span id="local-6989586621679061224"><span id="local-6989586621679061225"><span class="annot"><a href="Text.Parsec.Perm.html#%3C%24%3F%3E"><span class="hs-operator hs-type">(&lt;$?&gt;)</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Prim.html#Stream"><span class="hs-identifier hs-type">Stream</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061225"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="../../base/src/Data.Functor.Identity.html#Identity"><span class="hs-identifier hs-type">Identity</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061224"><span class="hs-identifier hs-type">tok</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679061223"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679061222"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679061223"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Text.Parsec.Prim.html#Parsec"><span class="hs-identifier hs-type">Parsec</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061225"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061221"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061223"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#StreamPermParser"><span class="hs-identifier hs-type">StreamPermParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061225"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061221"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061222"><span class="hs-identifier hs-type">b</span></a></span></span></span></span></span></span><span>
</span><span id="line-120"></span><span id="%3C%24%3F%3E"><span class="annot"><span class="annottext">&lt;$?&gt; :: forall s tok a b st.
Stream s Identity tok =&gt;
(a -&gt; b) -&gt; (a, Parsec s st a) -&gt; StreamPermParser s st b
</span><a href="Text.Parsec.Perm.html#%3C%24%3F%3E"><span class="hs-operator hs-var hs-var">(&lt;$?&gt;)</span></a></span></span><span> </span><span id="local-6989586621679061106"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679061106"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679061105"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679061105"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679061104"><span class="annot"><span class="annottext">Parsec s st a
</span><a href="#local-6989586621679061104"><span class="hs-identifier hs-var">p</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a -&gt; b) -&gt; StreamPermParser s st (a -&gt; b)
forall s tok a b st.
Stream s Identity tok =&gt;
(a -&gt; b) -&gt; StreamPermParser s st (a -&gt; b)
</span><a href="Text.Parsec.Perm.html#newperm"><span class="hs-identifier hs-var">newperm</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679061106"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">StreamPermParser s st (a -&gt; b)
-&gt; (a, Parsec s st a) -&gt; StreamPermParser s st b
forall s tok st a b.
Stream s Identity tok =&gt;
StreamPermParser s st (a -&gt; b)
-&gt; (a, Parsec s st a) -&gt; StreamPermParser s st b
</span><a href="Text.Parsec.Perm.html#%3C%7C%3F%3E"><span class="hs-operator hs-var">&lt;|?&gt;</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679061105"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Parsec s st a
</span><a href="#local-6989586621679061104"><span class="hs-identifier hs-var">p</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-121"></span><span>
</span><span id="line-122"></span><span class="hs-comment">{---------------------------------------------------------------
  The permutation tree
---------------------------------------------------------------}</span><span>
</span><span id="line-125"></span><span>
</span><span id="line-126"></span><span class="hs-comment">-- | Provided for backwards compatibility.  The tok type is ignored.</span><span>
</span><span id="line-127"></span><span>
</span><span id="line-128"></span><span class="hs-keyword">type</span><span> </span><span id="PermParser"><span class="annot"><a href="Text.Parsec.Perm.html#PermParser"><span class="hs-identifier hs-var">PermParser</span></a></span></span><span> </span><span id="local-6989586621679061103"><span class="annot"><a href="#local-6989586621679061103"><span class="hs-identifier hs-type">tok</span></a></span></span><span> </span><span id="local-6989586621679061102"><span class="annot"><a href="#local-6989586621679061102"><span class="hs-identifier hs-type">st</span></a></span></span><span> </span><span id="local-6989586621679061101"><span class="annot"><a href="#local-6989586621679061101"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#StreamPermParser"><span class="hs-identifier hs-type">StreamPermParser</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061102"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061101"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-129"></span><span>
</span><span id="line-130"></span><span class="hs-comment">-- | The type @StreamPermParser s st a@ denotes a permutation parser that,</span><span>
</span><span id="line-131"></span><span class="hs-comment">-- when converted by the 'permute' function, parses</span><span>
</span><span id="line-132"></span><span class="hs-comment">-- @s@ streams with user state @st@ and returns a value of</span><span>
</span><span id="line-133"></span><span class="hs-comment">-- type @a@ on success.</span><span>
</span><span id="line-134"></span><span class="hs-comment">--</span><span>
</span><span id="line-135"></span><span class="hs-comment">-- Normally, a permutation parser is first build with special operators</span><span>
</span><span id="line-136"></span><span class="hs-comment">-- like ('&lt;||&gt;') and than transformed into a normal parser</span><span>
</span><span id="line-137"></span><span class="hs-comment">-- using 'permute'.</span><span>
</span><span id="line-138"></span><span>
</span><span id="line-139"></span><span class="hs-keyword">data</span><span> </span><span id="StreamPermParser"><span class="annot"><a href="Text.Parsec.Perm.html#StreamPermParser"><span class="hs-identifier hs-var">StreamPermParser</span></a></span></span><span> </span><span id="local-6989586621679061180"><span class="annot"><a href="#local-6989586621679061180"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span id="local-6989586621679061179"><span class="annot"><a href="#local-6989586621679061179"><span class="hs-identifier hs-type">st</span></a></span></span><span> </span><span id="local-6989586621679061181"><span class="annot"><a href="#local-6989586621679061181"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="Perm"><span class="annot"><a href="Text.Parsec.Perm.html#Perm"><span class="hs-identifier hs-var">Perm</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061181"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="Text.Parsec.Perm.html#StreamBranch"><span class="hs-identifier hs-type">StreamBranch</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061180"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061179"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061181"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span class="hs-cpp">
#if MIN_VERSION_base(4,7,0)
</span><span>    </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.Typeable.Internal.html#Typeable"><span class="hs-identifier hs-type">Typeable</span></a></span><span> </span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">deriving</span><span> </span><span class="hs-keyword">instance</span><span> </span><span class="hs-identifier">Typeable3</span><span> </span><span class="hs-identifier">StreamPermParser</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-146"></span><span class="hs-comment">-- type Branch st a = StreamBranch String st a</span><span>
</span><span id="line-147"></span><span>
</span><span id="line-148"></span><span class="hs-keyword">data</span><span> </span><span id="StreamBranch"><span class="annot"><a href="Text.Parsec.Perm.html#StreamBranch"><span class="hs-identifier hs-var">StreamBranch</span></a></span></span><span> </span><span id="local-6989586621679061171"><span class="annot"><a href="#local-6989586621679061171"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span id="local-6989586621679061170"><span class="annot"><a href="#local-6989586621679061170"><span class="hs-identifier hs-type">st</span></a></span></span><span> </span><span id="local-6989586621679061168"><span class="annot"><a href="#local-6989586621679061168"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679061169"><span class="annot"><a href="#local-6989586621679061169"><span class="hs-identifier hs-type">b</span></a></span></span><span class="hs-operator">.</span><span> </span><span id="Branch"><span class="annot"><a href="Text.Parsec.Perm.html#Branch"><span class="hs-identifier hs-var">Branch</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Perm.html#StreamPermParser"><span class="hs-identifier hs-type">StreamPermParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061171"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061170"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679061169"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679061168"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Prim.html#Parsec"><span class="hs-identifier hs-type">Parsec</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061171"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061170"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061169"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#if MIN_VERSION_base(4,7,0)
</span><span>    </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.Typeable.Internal.html#Typeable"><span class="hs-identifier hs-type">Typeable</span></a></span><span> </span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">deriving</span><span> </span><span class="hs-keyword">instance</span><span> </span><span class="hs-identifier">Typeable3</span><span> </span><span class="hs-identifier">StreamBranch</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-155"></span><span class="hs-comment">-- | The parser @permute perm@ parses a permutation of parser described</span><span>
</span><span id="line-156"></span><span class="hs-comment">-- by @perm@. For example, suppose we want to parse a permutation of:</span><span>
</span><span id="line-157"></span><span class="hs-comment">-- an optional string of @a@'s, the character @b@ and an optional @c@.</span><span>
</span><span id="line-158"></span><span class="hs-comment">-- This can be described by:</span><span>
</span><span id="line-159"></span><span class="hs-comment">--</span><span>
</span><span id="line-160"></span><span class="hs-comment">-- &gt;  test  = permute (tuple &lt;$?&gt; (&quot;&quot;,many1 (char 'a'))</span><span>
</span><span id="line-161"></span><span class="hs-comment">-- &gt;                         &lt;||&gt; char 'b'</span><span>
</span><span id="line-162"></span><span class="hs-comment">-- &gt;                         &lt;|?&gt; ('_',char 'c'))</span><span>
</span><span id="line-163"></span><span class="hs-comment">-- &gt;        where</span><span>
</span><span id="line-164"></span><span class="hs-comment">-- &gt;          tuple a b c  = (a,b,c)</span><span>
</span><span id="line-165"></span><span>
</span><span id="line-166"></span><span class="hs-comment">-- transform a permutation tree into a normal parser</span><span>
</span><span id="line-167"></span><span id="local-6989586621679061212"><span id="local-6989586621679061213"><span id="local-6989586621679061214"><span id="local-6989586621679061215"><span class="annot"><a href="Text.Parsec.Perm.html#permute"><span class="hs-identifier hs-type">permute</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Prim.html#Stream"><span class="hs-identifier hs-type">Stream</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061215"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="../../base/src/Data.Functor.Identity.html#Identity"><span class="hs-identifier hs-type">Identity</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061214"><span class="hs-identifier hs-type">tok</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#StreamPermParser"><span class="hs-identifier hs-type">StreamPermParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061215"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061213"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061212"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Prim.html#Parsec"><span class="hs-identifier hs-type">Parsec</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061215"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061213"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061212"><span class="hs-identifier hs-type">a</span></a></span></span></span></span></span><span>
</span><span id="line-168"></span><span id="permute"><span class="annot"><span class="annottext">permute :: forall s tok st a.
Stream s Identity tok =&gt;
StreamPermParser s st a -&gt; Parsec s st a
</span><a href="Text.Parsec.Perm.html#permute"><span class="hs-identifier hs-var hs-var">permute</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Perm.html#Perm"><span class="hs-identifier hs-type">Perm</span></a></span><span> </span><span id="local-6989586621679061095"><span class="annot"><span class="annottext">Maybe a
</span><a href="#local-6989586621679061095"><span class="hs-identifier hs-var">def</span></a></span></span><span> </span><span id="local-6989586621679061094"><span class="annot"><span class="annottext">[StreamBranch s st a]
</span><a href="#local-6989586621679061094"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-169"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ParsecT s st Identity a] -&gt; ParsecT s st Identity a
forall s (m :: * -&gt; *) t u a.
Stream s m t =&gt;
[ParsecT s u m a] -&gt; ParsecT s u m a
</span><a href="Text.Parsec.Combinator.html#choice"><span class="hs-identifier hs-var">choice</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(StreamBranch s st a -&gt; ParsecT s st Identity a)
-&gt; [StreamBranch s st a] -&gt; [ParsecT s st Identity a]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">StreamBranch s st a -&gt; ParsecT s st Identity a
forall {s} {tok} {st} {a}.
Stream s Identity tok =&gt;
StreamBranch s st a -&gt; ParsecT s st Identity a
</span><a href="#local-6989586621679061092"><span class="hs-identifier hs-var">branch</span></a></span><span> </span><span class="annot"><span class="annottext">[StreamBranch s st a]
</span><a href="#local-6989586621679061094"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">[ParsecT s st Identity a]
-&gt; [ParsecT s st Identity a] -&gt; [ParsecT s st Identity a]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[ParsecT s st Identity a]
</span><a href="#local-6989586621679061091"><span class="hs-identifier hs-var">empty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-170"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-171"></span><span>    </span><span id="local-6989586621679061091"><span class="annot"><span class="annottext">empty :: [ParsecT s st Identity a]
</span><a href="#local-6989586621679061091"><span class="hs-identifier hs-var hs-var">empty</span></a></span></span><span>
</span><span id="line-172"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe a
</span><a href="#local-6989586621679061095"><span class="hs-identifier hs-var">def</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-173"></span><span>          </span><span class="annot"><span class="annottext">Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-174"></span><span>          </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679061088"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679061088"><span class="hs-identifier hs-var">x</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">a -&gt; ParsecT s st Identity a
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679061088"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-175"></span><span>
</span><span id="line-176"></span><span>    </span><span id="local-6989586621679061092"><span class="annot"><span class="annottext">branch :: StreamBranch s st a -&gt; ParsecT s st Identity a
</span><a href="#local-6989586621679061092"><span class="hs-identifier hs-var hs-var">branch</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Perm.html#Branch"><span class="hs-identifier hs-type">Branch</span></a></span><span> </span><span id="local-6989586621679061082"><span class="annot"><span class="annottext">StreamPermParser s st (b -&gt; a)
</span><a href="#local-6989586621679061082"><span class="hs-identifier hs-var">perm</span></a></span></span><span> </span><span id="local-6989586621679061081"><span class="annot"><span class="annottext">Parsec s st b
</span><a href="#local-6989586621679061081"><span class="hs-identifier hs-var">p</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-177"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span class="hs-special">{</span><span> </span><span id="local-6989586621679061080"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679061080"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Parsec s st b
</span><a href="#local-6989586621679061081"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-178"></span><span>          </span><span class="hs-special">;</span><span> </span><span id="local-6989586621679061079"><span class="annot"><span class="annottext">b -&gt; a
</span><a href="#local-6989586621679061079"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">StreamPermParser s st (b -&gt; a) -&gt; Parsec s st (b -&gt; a)
forall s tok st a.
Stream s Identity tok =&gt;
StreamPermParser s st a -&gt; Parsec s st a
</span><a href="Text.Parsec.Perm.html#permute"><span class="hs-identifier hs-var">permute</span></a></span><span> </span><span class="annot"><span class="annottext">StreamPermParser s st (b -&gt; a)
</span><a href="#local-6989586621679061082"><span class="hs-identifier hs-var">perm</span></a></span><span>
</span><span id="line-179"></span><span>          </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">a -&gt; ParsecT s st Identity a
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">b -&gt; a
</span><a href="#local-6989586621679061079"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679061080"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-180"></span><span>          </span><span class="hs-special">}</span><span>
</span><span id="line-181"></span><span>
</span><span id="line-182"></span><span class="hs-comment">-- build permutation trees</span><span>
</span><span id="line-183"></span><span id="local-6989586621679061241"><span id="local-6989586621679061242"><span id="local-6989586621679061243"><span id="local-6989586621679061244"><span id="local-6989586621679061245"><span class="annot"><a href="Text.Parsec.Perm.html#newperm"><span class="hs-identifier hs-type">newperm</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Prim.html#Stream"><span class="hs-identifier hs-type">Stream</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061245"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="../../base/src/Data.Functor.Identity.html#Identity"><span class="hs-identifier hs-type">Identity</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061244"><span class="hs-identifier hs-type">tok</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679061243"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679061242"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#StreamPermParser"><span class="hs-identifier hs-type">StreamPermParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061245"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061241"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679061243"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679061242"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span></span></span></span></span></span><span>
</span><span id="line-184"></span><span id="newperm"><span class="annot"><span class="annottext">newperm :: forall s tok a b st.
Stream s Identity tok =&gt;
(a -&gt; b) -&gt; StreamPermParser s st (a -&gt; b)
</span><a href="Text.Parsec.Perm.html#newperm"><span class="hs-identifier hs-var hs-var">newperm</span></a></span></span><span> </span><span id="local-6989586621679061077"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679061077"><span class="hs-identifier hs-var">f</span></a></span></span><span>
</span><span id="line-185"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (a -&gt; b)
-&gt; [StreamBranch s st (a -&gt; b)] -&gt; StreamPermParser s st (a -&gt; b)
forall s st a.
Maybe a -&gt; [StreamBranch s st a] -&gt; StreamPermParser s st a
</span><a href="Text.Parsec.Perm.html#Perm"><span class="hs-identifier hs-var">Perm</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; b) -&gt; Maybe (a -&gt; b)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679061077"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-186"></span><span>
</span><span id="line-187"></span><span id="local-6989586621679061072"><span id="local-6989586621679061073"><span id="local-6989586621679061074"><span id="local-6989586621679061075"><span id="local-6989586621679061076"><span class="annot"><a href="Text.Parsec.Perm.html#add"><span class="hs-identifier hs-type">add</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Prim.html#Stream"><span class="hs-identifier hs-type">Stream</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061076"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="../../base/src/Data.Functor.Identity.html#Identity"><span class="hs-identifier hs-type">Identity</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061075"><span class="hs-identifier hs-type">tok</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#StreamPermParser"><span class="hs-identifier hs-type">StreamPermParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061076"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061074"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679061073"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679061072"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Prim.html#Parsec"><span class="hs-identifier hs-type">Parsec</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061076"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061074"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061073"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#StreamPermParser"><span class="hs-identifier hs-type">StreamPermParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061076"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061074"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061072"><span class="hs-identifier hs-type">b</span></a></span></span></span></span></span></span><span>
</span><span id="line-188"></span><span id="add"><span class="annot"><span class="annottext">add :: forall s tok st a b.
Stream s Identity tok =&gt;
StreamPermParser s st (a -&gt; b)
-&gt; Parsec s st a -&gt; StreamPermParser s st b
</span><a href="Text.Parsec.Perm.html#add"><span class="hs-identifier hs-var hs-var">add</span></a></span></span><span> </span><span id="local-6989586621679061069"><span class="annot"><span class="annottext">perm :: StreamPermParser s st (a -&gt; b)
</span><a href="#local-6989586621679061069"><span class="hs-identifier hs-var">perm</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Perm.html#Perm"><span class="hs-identifier hs-type">Perm</span></a></span><span> </span><span id="local-6989586621679061068"><span class="annot"><span class="annottext">Maybe (a -&gt; b)
</span><a href="#local-6989586621679061068"><span class="hs-identifier hs-var">_mf</span></a></span></span><span> </span><span id="local-6989586621679061067"><span class="annot"><span class="annottext">[StreamBranch s st (a -&gt; b)]
</span><a href="#local-6989586621679061067"><span class="hs-identifier hs-var">fs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679061066"><span class="annot"><span class="annottext">Parsec s st a
</span><a href="#local-6989586621679061066"><span class="hs-identifier hs-var">p</span></a></span></span><span>
</span><span id="line-189"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe b -&gt; [StreamBranch s st b] -&gt; StreamPermParser s st b
forall s st a.
Maybe a -&gt; [StreamBranch s st a] -&gt; StreamPermParser s st a
</span><a href="Text.Parsec.Perm.html#Perm"><span class="hs-identifier hs-var">Perm</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe b
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StreamBranch s st b
</span><a href="#local-6989586621679061065"><span class="hs-identifier hs-var">first</span></a></span><span class="annot"><span class="annottext">StreamBranch s st b
-&gt; [StreamBranch s st b] -&gt; [StreamBranch s st b]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">(StreamBranch s st (a -&gt; b) -&gt; StreamBranch s st b)
-&gt; [StreamBranch s st (a -&gt; b)] -&gt; [StreamBranch s st b]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">StreamBranch s st (a -&gt; b) -&gt; StreamBranch s st b
forall {tok} {a}.
Stream s Identity tok =&gt;
StreamBranch s st (a -&gt; a) -&gt; StreamBranch s st a
</span><a href="#local-6989586621679061064"><span class="hs-identifier hs-var">insert</span></a></span><span> </span><span class="annot"><span class="annottext">[StreamBranch s st (a -&gt; b)]
</span><a href="#local-6989586621679061067"><span class="hs-identifier hs-var">fs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-190"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-191"></span><span>    </span><span id="local-6989586621679061065"><span class="annot"><span class="annottext">first :: StreamBranch s st b
</span><a href="#local-6989586621679061065"><span class="hs-identifier hs-var hs-var">first</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StreamPermParser s st (a -&gt; b)
-&gt; Parsec s st a -&gt; StreamBranch s st b
forall s st a b.
StreamPermParser s st (b -&gt; a)
-&gt; Parsec s st b -&gt; StreamBranch s st a
</span><a href="Text.Parsec.Perm.html#Branch"><span class="hs-identifier hs-var">Branch</span></a></span><span> </span><span class="annot"><span class="annottext">StreamPermParser s st (a -&gt; b)
</span><a href="#local-6989586621679061069"><span class="hs-identifier hs-var">perm</span></a></span><span> </span><span class="annot"><span class="annottext">Parsec s st a
</span><a href="#local-6989586621679061066"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-192"></span><span>    </span><span id="local-6989586621679061064"><span class="annot"><span class="annottext">insert :: StreamBranch s st (a -&gt; a) -&gt; StreamBranch s st a
</span><a href="#local-6989586621679061064"><span class="hs-identifier hs-var hs-var">insert</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Perm.html#Branch"><span class="hs-identifier hs-type">Branch</span></a></span><span> </span><span id="local-6989586621679061060"><span class="annot"><span class="annottext">StreamPermParser s st (b -&gt; a -&gt; a)
</span><a href="#local-6989586621679061060"><span class="hs-identifier hs-var">perm'</span></a></span></span><span> </span><span id="local-6989586621679061059"><span class="annot"><span class="annottext">Parsec s st b
</span><a href="#local-6989586621679061059"><span class="hs-identifier hs-var">p'</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-193"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StreamPermParser s st (b -&gt; a)
-&gt; Parsec s st b -&gt; StreamBranch s st a
forall s st a b.
StreamPermParser s st (b -&gt; a)
-&gt; Parsec s st b -&gt; StreamBranch s st a
</span><a href="Text.Parsec.Perm.html#Branch"><span class="hs-identifier hs-var">Branch</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StreamPermParser s st (a -&gt; b -&gt; a)
-&gt; Parsec s st a -&gt; StreamPermParser s st (b -&gt; a)
forall s tok st a b.
Stream s Identity tok =&gt;
StreamPermParser s st (a -&gt; b)
-&gt; Parsec s st a -&gt; StreamPermParser s st b
</span><a href="Text.Parsec.Perm.html#add"><span class="hs-identifier hs-var">add</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((b -&gt; a -&gt; a) -&gt; a -&gt; b -&gt; a)
-&gt; StreamPermParser s st (b -&gt; a -&gt; a)
-&gt; StreamPermParser s st (a -&gt; b -&gt; a)
forall s tok a b st.
Stream s Identity tok =&gt;
(a -&gt; b) -&gt; StreamPermParser s st a -&gt; StreamPermParser s st b
</span><a href="Text.Parsec.Perm.html#mapPerms"><span class="hs-identifier hs-var">mapPerms</span></a></span><span> </span><span class="annot"><span class="annottext">(b -&gt; a -&gt; a) -&gt; a -&gt; b -&gt; a
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="annot"><span class="annottext">StreamPermParser s st (b -&gt; a -&gt; a)
</span><a href="#local-6989586621679061060"><span class="hs-identifier hs-var">perm'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Parsec s st a
</span><a href="#local-6989586621679061066"><span class="hs-identifier hs-var">p</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Parsec s st b
</span><a href="#local-6989586621679061059"><span class="hs-identifier hs-var">p'</span></a></span><span>
</span><span id="line-194"></span><span>
</span><span id="line-195"></span><span id="local-6989586621679061226"><span id="local-6989586621679061227"><span id="local-6989586621679061228"><span id="local-6989586621679061229"><span id="local-6989586621679061230"><span class="annot"><a href="Text.Parsec.Perm.html#addopt"><span class="hs-identifier hs-type">addopt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Prim.html#Stream"><span class="hs-identifier hs-type">Stream</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061230"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="../../base/src/Data.Functor.Identity.html#Identity"><span class="hs-identifier hs-type">Identity</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061229"><span class="hs-identifier hs-type">tok</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#StreamPermParser"><span class="hs-identifier hs-type">StreamPermParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061230"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061228"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679061227"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679061226"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679061227"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Prim.html#Parsec"><span class="hs-identifier hs-type">Parsec</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061230"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061228"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061227"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#StreamPermParser"><span class="hs-identifier hs-type">StreamPermParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061230"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061228"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061226"><span class="hs-identifier hs-type">b</span></a></span></span></span></span></span></span><span>
</span><span id="line-196"></span><span id="addopt"><span class="annot"><span class="annottext">addopt :: forall s tok st a b.
Stream s Identity tok =&gt;
StreamPermParser s st (a -&gt; b)
-&gt; a -&gt; Parsec s st a -&gt; StreamPermParser s st b
</span><a href="Text.Parsec.Perm.html#addopt"><span class="hs-identifier hs-var hs-var">addopt</span></a></span></span><span> </span><span id="local-6989586621679061052"><span class="annot"><span class="annottext">perm :: StreamPermParser s st (a -&gt; b)
</span><a href="#local-6989586621679061052"><span class="hs-identifier hs-var">perm</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Perm.html#Perm"><span class="hs-identifier hs-type">Perm</span></a></span><span> </span><span id="local-6989586621679061051"><span class="annot"><span class="annottext">Maybe (a -&gt; b)
</span><a href="#local-6989586621679061051"><span class="hs-identifier hs-var">mf</span></a></span></span><span> </span><span id="local-6989586621679061050"><span class="annot"><span class="annottext">[StreamBranch s st (a -&gt; b)]
</span><a href="#local-6989586621679061050"><span class="hs-identifier hs-var">fs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679061049"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679061049"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621679061048"><span class="annot"><span class="annottext">Parsec s st a
</span><a href="#local-6989586621679061048"><span class="hs-identifier hs-var">p</span></a></span></span><span>
</span><span id="line-197"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe b -&gt; [StreamBranch s st b] -&gt; StreamPermParser s st b
forall s st a.
Maybe a -&gt; [StreamBranch s st a] -&gt; StreamPermParser s st a
</span><a href="Text.Parsec.Perm.html#Perm"><span class="hs-identifier hs-var">Perm</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((a -&gt; b) -&gt; b) -&gt; Maybe (a -&gt; b) -&gt; Maybe b
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; b) -&gt; a -&gt; b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679061049"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe (a -&gt; b)
</span><a href="#local-6989586621679061051"><span class="hs-identifier hs-var">mf</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StreamBranch s st b
</span><a href="#local-6989586621679061047"><span class="hs-identifier hs-var">first</span></a></span><span class="annot"><span class="annottext">StreamBranch s st b
-&gt; [StreamBranch s st b] -&gt; [StreamBranch s st b]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">(StreamBranch s st (a -&gt; b) -&gt; StreamBranch s st b)
-&gt; [StreamBranch s st (a -&gt; b)] -&gt; [StreamBranch s st b]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">StreamBranch s st (a -&gt; b) -&gt; StreamBranch s st b
forall {tok} {a}.
Stream s Identity tok =&gt;
StreamBranch s st (a -&gt; a) -&gt; StreamBranch s st a
</span><a href="#local-6989586621679061046"><span class="hs-identifier hs-var">insert</span></a></span><span> </span><span class="annot"><span class="annottext">[StreamBranch s st (a -&gt; b)]
</span><a href="#local-6989586621679061050"><span class="hs-identifier hs-var">fs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-198"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-199"></span><span>    </span><span id="local-6989586621679061047"><span class="annot"><span class="annottext">first :: StreamBranch s st b
</span><a href="#local-6989586621679061047"><span class="hs-identifier hs-var hs-var">first</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StreamPermParser s st (a -&gt; b)
-&gt; Parsec s st a -&gt; StreamBranch s st b
forall s st a b.
StreamPermParser s st (b -&gt; a)
-&gt; Parsec s st b -&gt; StreamBranch s st a
</span><a href="Text.Parsec.Perm.html#Branch"><span class="hs-identifier hs-var">Branch</span></a></span><span> </span><span class="annot"><span class="annottext">StreamPermParser s st (a -&gt; b)
</span><a href="#local-6989586621679061052"><span class="hs-identifier hs-var">perm</span></a></span><span> </span><span class="annot"><span class="annottext">Parsec s st a
</span><a href="#local-6989586621679061048"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-200"></span><span>    </span><span id="local-6989586621679061046"><span class="annot"><span class="annottext">insert :: StreamBranch s st (a -&gt; a) -&gt; StreamBranch s st a
</span><a href="#local-6989586621679061046"><span class="hs-identifier hs-var hs-var">insert</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Perm.html#Branch"><span class="hs-identifier hs-type">Branch</span></a></span><span> </span><span id="local-6989586621679061042"><span class="annot"><span class="annottext">StreamPermParser s st (b -&gt; a -&gt; a)
</span><a href="#local-6989586621679061042"><span class="hs-identifier hs-var">perm'</span></a></span></span><span> </span><span id="local-6989586621679061041"><span class="annot"><span class="annottext">Parsec s st b
</span><a href="#local-6989586621679061041"><span class="hs-identifier hs-var">p'</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-201"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StreamPermParser s st (b -&gt; a)
-&gt; Parsec s st b -&gt; StreamBranch s st a
forall s st a b.
StreamPermParser s st (b -&gt; a)
-&gt; Parsec s st b -&gt; StreamBranch s st a
</span><a href="Text.Parsec.Perm.html#Branch"><span class="hs-identifier hs-var">Branch</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StreamPermParser s st (a -&gt; b -&gt; a)
-&gt; a -&gt; Parsec s st a -&gt; StreamPermParser s st (b -&gt; a)
forall s tok st a b.
Stream s Identity tok =&gt;
StreamPermParser s st (a -&gt; b)
-&gt; a -&gt; Parsec s st a -&gt; StreamPermParser s st b
</span><a href="Text.Parsec.Perm.html#addopt"><span class="hs-identifier hs-var">addopt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((b -&gt; a -&gt; a) -&gt; a -&gt; b -&gt; a)
-&gt; StreamPermParser s st (b -&gt; a -&gt; a)
-&gt; StreamPermParser s st (a -&gt; b -&gt; a)
forall s tok a b st.
Stream s Identity tok =&gt;
(a -&gt; b) -&gt; StreamPermParser s st a -&gt; StreamPermParser s st b
</span><a href="Text.Parsec.Perm.html#mapPerms"><span class="hs-identifier hs-var">mapPerms</span></a></span><span> </span><span class="annot"><span class="annottext">(b -&gt; a -&gt; a) -&gt; a -&gt; b -&gt; a
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="annot"><span class="annottext">StreamPermParser s st (b -&gt; a -&gt; a)
</span><a href="#local-6989586621679061042"><span class="hs-identifier hs-var">perm'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679061049"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Parsec s st a
</span><a href="#local-6989586621679061048"><span class="hs-identifier hs-var">p</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Parsec s st b
</span><a href="#local-6989586621679061041"><span class="hs-identifier hs-var">p'</span></a></span><span>
</span><span id="line-202"></span><span>
</span><span id="line-203"></span><span>
</span><span id="line-204"></span><span id="local-6989586621679061162"><span id="local-6989586621679061163"><span id="local-6989586621679061164"><span id="local-6989586621679061165"><span id="local-6989586621679061166"><span class="annot"><a href="Text.Parsec.Perm.html#mapPerms"><span class="hs-identifier hs-type">mapPerms</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Prim.html#Stream"><span class="hs-identifier hs-type">Stream</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061166"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="../../base/src/Data.Functor.Identity.html#Identity"><span class="hs-identifier hs-type">Identity</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061165"><span class="hs-identifier hs-type">tok</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679061164"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679061163"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#StreamPermParser"><span class="hs-identifier hs-type">StreamPermParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061166"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061162"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061164"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Text.Parsec.Perm.html#StreamPermParser"><span class="hs-identifier hs-type">StreamPermParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061166"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061162"><span class="hs-identifier hs-type">st</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061163"><span class="hs-identifier hs-type">b</span></a></span></span></span></span></span></span><span>
</span><span id="line-205"></span><span id="mapPerms"><span class="annot"><span class="annottext">mapPerms :: forall s tok a b st.
Stream s Identity tok =&gt;
(a -&gt; b) -&gt; StreamPermParser s st a -&gt; StreamPermParser s st b
</span><a href="Text.Parsec.Perm.html#mapPerms"><span class="hs-identifier hs-var hs-var">mapPerms</span></a></span></span><span> </span><span id="local-6989586621679061037"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679061037"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Perm.html#Perm"><span class="hs-identifier hs-type">Perm</span></a></span><span> </span><span id="local-6989586621679061036"><span class="annot"><span class="annottext">Maybe a
</span><a href="#local-6989586621679061036"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621679061035"><span class="annot"><span class="annottext">[StreamBranch s st a]
</span><a href="#local-6989586621679061035"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-206"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe b -&gt; [StreamBranch s st b] -&gt; StreamPermParser s st b
forall s st a.
Maybe a -&gt; [StreamBranch s st a] -&gt; StreamPermParser s st a
</span><a href="Text.Parsec.Perm.html#Perm"><span class="hs-identifier hs-var">Perm</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; b) -&gt; Maybe a -&gt; Maybe b
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679061037"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe a
</span><a href="#local-6989586621679061036"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(StreamBranch s st a -&gt; StreamBranch s st b)
-&gt; [StreamBranch s st a] -&gt; [StreamBranch s st b]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">StreamBranch s st a -&gt; StreamBranch s st b
forall {s} {tok} {st}.
Stream s Identity tok =&gt;
StreamBranch s st a -&gt; StreamBranch s st b
</span><a href="#local-6989586621679061034"><span class="hs-identifier hs-var">mapBranch</span></a></span><span> </span><span class="annot"><span class="annottext">[StreamBranch s st a]
</span><a href="#local-6989586621679061035"><span class="hs-identifier hs-var">xs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-207"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-208"></span><span>    </span><span id="local-6989586621679061034"><span class="annot"><span class="annottext">mapBranch :: StreamBranch s st a -&gt; StreamBranch s st b
</span><a href="#local-6989586621679061034"><span class="hs-identifier hs-var hs-var">mapBranch</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Text.Parsec.Perm.html#Branch"><span class="hs-identifier hs-type">Branch</span></a></span><span> </span><span id="local-6989586621679061031"><span class="annot"><span class="annottext">StreamPermParser s st (b -&gt; a)
</span><a href="#local-6989586621679061031"><span class="hs-identifier hs-var">perm</span></a></span></span><span> </span><span id="local-6989586621679061030"><span class="annot"><span class="annottext">Parsec s st b
</span><a href="#local-6989586621679061030"><span class="hs-identifier hs-var">p</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-209"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StreamPermParser s st (b -&gt; b)
-&gt; Parsec s st b -&gt; StreamBranch s st b
forall s st a b.
StreamPermParser s st (b -&gt; a)
-&gt; Parsec s st b -&gt; StreamBranch s st a
</span><a href="Text.Parsec.Perm.html#Branch"><span class="hs-identifier hs-var">Branch</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((b -&gt; a) -&gt; b -&gt; b)
-&gt; StreamPermParser s st (b -&gt; a) -&gt; StreamPermParser s st (b -&gt; b)
forall s tok a b st.
Stream s Identity tok =&gt;
(a -&gt; b) -&gt; StreamPermParser s st a -&gt; StreamPermParser s st b
</span><a href="Text.Parsec.Perm.html#mapPerms"><span class="hs-identifier hs-var">mapPerms</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679061037"><span class="hs-identifier hs-var">f</span></a></span><span class="annot"><span class="annottext">(a -&gt; b) -&gt; (b -&gt; a) -&gt; b -&gt; b
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">StreamPermParser s st (b -&gt; a)
</span><a href="#local-6989586621679061031"><span class="hs-identifier hs-var">perm</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Parsec s st b
</span><a href="#local-6989586621679061030"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-210"></span></pre></body></html>